//先导入一些必须的东西
import {
    RoleFormData,
    RoleItem,
  } from '@/types';
  import request from '@/utils/request';
  import { AxiosPromise } from 'axios';

/**
 * 获取角色列表
 *
 * @param queryParams
 */
 export function listRoles(
  ): AxiosPromise<RoleItem[]> {
    return request({
      url: '/role?action=list',
      method: 'get',
    });
  }

  /**
 * 获取角色详情
 *
 * @param id
 */
export function getRoleFormDetail(id: number): AxiosPromise<RoleFormData> {
  return request({
    url: '/role?action=detail&id=' + id,
    method: 'get',
  });
}

  /**
 * 添加角色
 *
 * @param data
 */
export function addRole(data: RoleFormData) {
  console.log(data)
  return request({
    url: '/role',
    method: 'post',
    data: data,
  });
}

  /**
 * 修改角色
 *
 * @param id
 * @param data
 */
export function updateRole(id: number, data: RoleFormData) {
  return request({
    url: '/role',
    method: 'put',
    data: data,
  });
}
  /**
 * 删除角色
 *
 * @param ids
 */
export function deleteRole(ids: string) {
  return request({
    url: '/role?id=' + ids,
    method: 'delete',
  });
}
